#pragma once
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>


const std::string gpipeFile = "./fifo";

const mode_t gmode = 0600;

const int gdefault = -1;

const ssize_t gsize = 1024;

const int gRead = O_RDONLY;

const int gWrite = O_WRONLY;


int OpenPipe(int flag)
{
    //如果读端打开文件时，写段关闭，读端对应的open会阻塞！！！
    int fd = ::open(gpipeFile.c_str(),flag);
    if(fd < 0)
    {
      std::cerr <<"open error" << std::endl;
     
    }
    return fd;
}

void ClosePipeHelper(int fd)
{
    if(fd >= 0)
    {
      ::close(fd);
    }
}